package com.kaishengit.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.kaishengit.pojo.Deal;
import com.kaishengit.pojo.DealNote;
import com.kaishengit.pojo.User;
import com.kaishengit.service.DealNoteService;
import com.kaishengit.service.DealService;
import com.kaishengit.util.DateUtil;
import com.opensymphony.xwork2.ActionSupport;

public class DealNoteAction extends ActionSupport implements SessionAware {

	private static final long serialVersionUID = 1L;
	private DealNoteService dealNoteService;
	private DealNote dealNote;
	private List<DealNote> dealNoteList;
	private String id;
	private Map<String ,Object> session;
	private User user;
	private Deal deal;
	private DealService dealService;
	private Deal deals;
	private String content;
	
	
	public String saveDealNote(){
		
		user=(User) session.get("user");
		//System.out.println(id);
		deals=dealService.findById(id);
		//dealNote.setDeal(deals);
		dealNoteService.save(dealNote,user,deals);
		System.out.println(deals.getTitle());
		dealNoteList=dealNoteService.findByDealId(id);
		
		for(DealNote dealnotte:dealNoteList){
			System.out.println(dealnotte.getContent());
		}
		return SUCCESS;
		
		
	
	}
	
	public String deleteNote(){
		dealNote = dealNoteService.findById(id);
		dealNoteService.delete(id);
		deals=dealNote.getDeal();
		dealNoteList=dealNoteService.findByDealId(deals.getId());
		return "success";
	}
	
	
	
	//get set
	
	public DealNoteService getDealNoteService() {
		return dealNoteService;
	}
	










	public Deal getDeals() {
		return deals;
	}





	public void setDeals(Deal deals) {
		this.deals = deals;
	}





	public void setDealNoteService(DealNoteService dealNoteService) {
		this.dealNoteService = dealNoteService;
	}
	public DealNote getDealNote() {
		return dealNote;
	}
	public void setDealNote(DealNote dealNote) {
		this.dealNote = dealNote;
	}
	public List<DealNote> getDealNoteList() {
		return dealNoteList;
	}
	public void setDealNoteList(List<DealNote> dealNoteList) {
		this.dealNoteList = dealNoteList;
	}


	public String getId() {
		return id;
	}


	public void setId(String id) {
		this.id = id;
	}



	public void setSession(Map<String, Object> session) {
		this.session = session;
	}





	public User getUser() {
		return user;
	}





	public void setUser(User user) {
		this.user = user;
	}





	
	public Deal getDeal() {
		return deal;
	}





	public void setDeal(Deal deal) {
		this.deal = deal;
	}





	public DealService getDealService() {
		return dealService;
	}





	public void setDealService(DealService dealService) {
		this.dealService = dealService;
	}


	

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}


	
}
